package com.xjj.controller;

import com.xjj.entity.Parent;
import com.xjj.entity.ResponseEntity;
import com.xjj.service.ParentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author sxy
 * @version 1.0
 * @date 2022/10/20 17:03
 */
@RestController
@RequestMapping("/manage/admin/parent")
public class ParentController {
    @Resource
    private ParentService parentService;

    @PostMapping("/addParent")
    @ApiOperation(value = "添加家长")
    public ResponseEntity addParent(@RequestBody Parent parent){
        boolean save = parentService.save(parent);
        return new ResponseEntity<>(200,"ok",save);
    }

    @DeleteMapping("/deleteParentById/{id}")
    @ApiOperation(value = "通过id删除家长")
    public ResponseEntity deleteParentById(int id){
        boolean flag = parentService.removeById(id);
        return new ResponseEntity<>(200,"ok",flag);
    }

    @ApiOperation(value = "查找所有家长所有信息")
    @GetMapping("/findAllParent")
    public ResponseEntity findAllParent(){
        List<Parent> parents = parentService.list();
        return new ResponseEntity<>(200,"ok",parents);
    }
}
